package com.borqsprocessmanager.info;

import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;

public class ProcessStatsInfo extends SectionInfo implements
		Comparable<ProcessStatsInfo>, Parcelable {
	private final String TAG = "ProcessStatsInfo";

	public int sampleId;
	public int pid;
	public int uid;
	public int icon;
	public int isSystem;
	public int type;
	public long rx;
	public long tx;
	public long total;
	public double ratio;
	public String processName;
	public String packageName;
	public String appName;

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getSampleId() {
		return sampleId;
	}

	public void setSampleId(int sampleId) {
		this.sampleId = sampleId;
	}

	public int getUid() {
		return uid;
	}

	public void setUid(int uid) {
		this.uid = uid;
	}

	public int getIcon() {
		return icon;
	}

	public void setIcon(int icon) {
		this.icon = icon;
	}

	public int getIsSystem() {
		return isSystem;
	}

	public void setIsSystem(int isSystem) {
		this.isSystem = isSystem;
	}

	public long getRx() {
		return rx;
	}

	public void setRx(long rx) {
		this.rx = rx;
	}

	public long getTx() {
		return tx;
	}

	public void setTx(long tx) {
		this.tx = tx;
	}

	public long getTotal() {
		return total;
	}

	public void setTotal(long total) {
		this.total = total;
	}

	public int getPid() {
		return pid;
	}

	public void setPid(int pid) {
		this.pid = pid;
	}

	public double getRatio() {
		return ratio;
	}

	public void setRatio(double ratio) {
		this.ratio = ratio;
	}

	public String getProcessName() {
		return processName;
	}

	public void setProcessName(String processName) {
		this.processName = processName;
	}

	public String getPackageName() {
		return packageName;
	}

	public void setPackageName(String packageName) {
		this.packageName = packageName;
	}

	public String getAppName() {
		return appName;
	}

	public void setAppName(String appName) {
		this.appName = appName;
	}

	@Override
	public int compareTo(ProcessStatsInfo another) {
		int curtype = this.type;
		int anotherType = another.type;
		if (curtype == 1) {
			curtype = 3;
		} else if (curtype == 3) {
			curtype = 4;
		}
		if (anotherType == 1) {
			anotherType = 3;
		} else if (anotherType == 3) {
			anotherType = 4;
		}
		int res = anotherType - curtype;
		Log.v(TAG, "another.type==" + another.type);
		Log.v(TAG, "this.type==" + this.type);
		Log.v(TAG, "res==" + res);

		// if (res == 1) {
		// res += 2;
		// }
		return res;
	}

	// public int sampleId;
	// public int pid;
	// public int uid;
	// public int icon;
	// public int isSystem;
	// public int type;
	// public long rx;
	// public long tx;
	// public long total;
	// public double ratio;
	// public String processName;
	// public String packageName;
	// public String appName;

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(sampleId);
		dest.writeInt(pid);
		dest.writeInt(uid);
		dest.writeInt(icon);
		dest.writeInt(isSystem);
		dest.writeInt(type);
		dest.writeLong(rx);
		dest.writeLong(tx);
		dest.writeLong(total);
		dest.writeDouble(ratio);
		dest.writeString(processName);
		dest.writeString(packageName);
		dest.writeString(appName);
	}

	public static final Parcelable.Creator<ProcessStatsInfo> CREATOR = new Parcelable.Creator<ProcessStatsInfo>() {

		public ProcessStatsInfo createFromParcel(Parcel in) {
			return new ProcessStatsInfo(in);
		}

		public ProcessStatsInfo[] newArray(int size) {
			return new ProcessStatsInfo[size];
		}
	};

	public ProcessStatsInfo(Parcel in) {
		sampleId = in.readInt();
		pid = in.readInt();
		uid = in.readInt();
		icon = in.readInt();
		isSystem = in.readInt();
		type = in.readInt();
		rx = in.readLong();
		tx = in.readLong();
		total = in.readLong();
		ratio = in.readDouble();
		processName = in.readString();
		packageName = in.readString();
		appName = in.readString();
	}

	public ProcessStatsInfo() {
		// TODO Auto-generated constructor stub
	}
}
